<template>
	<view class="content">
		<view class="menu-item">
			<view class="tab-item" :class="tabActive==1?'active':''" @click="bindActive(1)">全部</view>
			<view class="tab-item" :class="tabActive==63?'active':''" @click="bindActive(63)">蓝灯项目</view>
			<view class="tab-item" :class="tabActive==64?'active':''" @click="bindActive(64)">黄灯项目</view>
			<view class="tab-item" :class="tabActive==65?'active':''" @click="bindActive(65)">红灯项目</view>
		</view>
		<view class="info-block">
			<!-- <view class="search-block" v-if="tabActive==1">
				<view class="input-block">
					<input placeholder="请输入项目名称" v-model="keyWords" @confirm="search" />
					<view class="iconfont icon-sousuo" @click="getList"></view>
				</view>
			</view> -->
			<view class="tips" style="background-color: #C5E0FB;" v-if="tabActive==63">
				<image src="/static/project/blue.png" class="img"></image>
				<view class="text">蓝灯项目： 进展较快，需持续跟进，共计<text class="total">{{count}}</text>个项目。</view>
			</view>
			<view class="tips" v-if="tabActive==64" style="background-color: #F7E6C8;">
				<image src="/static/project/yellow.png" class="img"></image>
				<view class="text">黄灯项目：有进展但进度较慢，需及时提醒协调推进，共计<text class="total">{{count}}</text>个项目。</view>
			</view>
			<view class="tips" v-if="tabActive==65" style="background-color: #F1C7C8;">
				<image src="/static/project/red.png" class="img"></image>
				<view class="text">红灯项目： 无进展，需跟踪督促，共计<text class="total">{{count}}</text>个项目。</view>
			</view>
			<template v-if="list.length>0">
				<view class="project-block" v-for="(item,index) in list" :key="item.id">
					<view class="title-item">
						<view class="round" v-if="item.status===64"></view>
						<view class="round1" v-else-if="item.status===63"></view>
						<view class="round2" v-else-if="item.status===65"></view>
						<view class="title">{{index+1}}、{{item.name}}</view>
					</view>
					<view class="build-item">
						<view class="build"><text class="txt">项目类型：</text>{{item.classText}}</view>
						<view class="build"><text class="txt">包抓领导：</text>{{item.leader}}</view>
						<view class="build"><text class="txt">责任单位：</text>{{item.departmentText}}</view>
						<view class="build"><text class="txt">主要建设规模：</text>{{item.scale}}</view>
					</view>
				</view>
			</template>
			<view v-else-if="list.length==0&&!listConf.more" style="text-align: center;">暂无数据</view>
			<view v-if="list.length>0&&!listConf.more" style="text-align: center;">没有更多了</view>
		</view>
	</view>
	</view>
</template>

<script>
	import {
		getProjectApi
	} from '@/api/project.js'
	import {
		isMore
	} from '@/util/util.js'
	export default {
		data() {
			return {
				tabActive: 1,
				keyWords: '',
				listConf: {
					page: 1,
					limit: 10,
					more: true,
				},
				list: [],
				count: 0
			}
		},
		methods: {
			bindActive(index) {
				this.tabActive = index
				this.listConf.page = 1
				this.getList(true)
				this.keyWords = ''
			},
			search() {
				this.getList(true)
			},
			getList(refresh = false) {
				uni.showLoading({
					title: '加载中',
					mask: true
				})
				getProjectApi({
					page: this.listConf.page,
					limit: this.listConf.limit,
					status: this.tabActive,
					name: this.keyWords
				}).then(data => {
					uni.hideLoading()
					let list = data.list || [];
					this.count = data.count
					if (refresh) {
						this.list = list;

					} else {
						this.list = [...this.list, ...list]
					}
					this.listConf.more = isMore(this.listConf.page, this.listConf.limit, data.count);
				}).catch(() => {
					uni.hideLoading()
				})
			}
		},
		onReachBottom() {
			if (this.listConf.more) {
				this.listConf.page++;
				this.getList()
			}
		},
		onLoad() {
			this.getList(true)
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		.menu-item {
			width: 100%;
			height: 200rpx;
			background-color: #157EFE;
			display: flex;
			flex-direction: row;
			justify-content: space-around;
			color: #fff;

			.tab-item {
				margin-top: 30rpx;
				height: 60rpx;
				font-size: 30rpx;
			}

			.tab-item.active {
				font-size: 34rpx;
				font-weight: bold;
				height: 60rpx;
				border-bottom: 6rpx solid #fff;
			}
		}

		.info-block {
			min-height: 80vh;
			display: flex;
			flex-direction: column;
			background: #F5F5F5;
			margin-top: -90rpx;
			border-radius: 40rpx;
			height: auto;
			position: relative;
			padding: 30rpx;

			.search-block {
				position: relative;
				width: 100%;
				height: 60rpx;
				//padding: 0 30rpx;
				display: flex;
				flex-direction: row;
				align-items: center;
				margin-bottom: 30rpx;

				.input-block {
					width: 100%;
					display: flex;
					flex-direction: row;
					align-items: center;
					border: 1px solid #808080;
					border-radius: 40rpx;
					padding: 0 10rpx;
					height: 60rpx;

					.iconfont {
						flex-grow: 0;
						color: #808080;
						margin: 0 10rpx;
					}

					input {
						flex-grow: 1;
						font-size: 28rpx;
						color: #808080;
						margin: 0 10rpx;
					}
				}
			}

			.tips {
				display: flex;
				flex-direction: row;
				align-items: center;
				padding: 30rpx;
				border-radius: 20rpx;
				margin-bottom: 30rpx;

				.img {
					width: 45rpx;
					height: 45rpx;
					margin-right: 20rpx;
				}

				.text {
					font-size: 32rpx;
					width: calc(100% - 80rpx);

					.total {
						font-weight: bold;
					}
				}
			}

			.project-block {
				background-color: #fff;
				border-radius: 20rpx;
				padding: 30rpx;
				margin-bottom: 30rpx;
				box-shadow: 0 0 10px 0 #dedede;

				.title-item {
					display: flex;
					flex-direction: row;

					.round {
						width: 40rpx;
						height: 40rpx;
						border-radius: 50%;
						background-color: #FFA101;
						margin-top: 12rpx;
						margin-right: 10rpx;
					}

					.round1 {
						width: 40rpx;
						height: 40rpx;
						border-radius: 50%;
						background-color: #127DFF;
						margin-top: 12rpx;
						margin-right: 10rpx;
					}

					.round2 {
						width: 40rpx;
						height: 40rpx;
						border-radius: 50%;
						background-color: #FE0000;
						margin-top: 12rpx;
						margin-right: 10rpx;
					}

					.title {
						width: calc(100% - 55rpx);
						font-size: 34rpx;
						font-weight: bold;
						line-height: 60rpx;
					}
				}

				.build-item {
					padding: 20rpx;
					background: #F5F5F5;
					line-height: 60rpx;
					border-radius: 20rpx;
					margin-top: 20rpx;

					.build {
						font-size: 28rpx;

						.txt {
							color: #999;
						}
					}
				}

				.total-list {
					width: 100%;
					display: flex;
					flex-direction: row;
					align-items: center;
					margin-top: 20rpx;
					justify-content: space-between;

					.total-item {
						display: flex;
						flex-direction: column;
						align-items: center;

						.money {
							font-weight: bold;
							font-size: 34rpx;
						}

						.text {
							font-size: 28rpx;
							color: #999;
							margin-top: 10rpx;
						}

						.status {
							display: flex;
							flex-direction: row;
							align-items: center;


							.text {
								font-size: 28rpx;
								color: #EF731B;
								font-weight: 600;
							}
						}

						.status2 {
							display: flex;
							flex-direction: row;
							align-items: center;

							.round {
								width: 30rpx;
								height: 30rpx;
								border-radius: 50%;
								background-color: #E30302;
								margin-top: 10rpx;
								margin-right: 10rpx;
							}

							.text {
								font-size: 28rpx;
								color: #E30302;
								font-weight: 600;
							}
						}

						.status3 {
							display: flex;
							flex-direction: row;
							align-items: center;

							.round {
								width: 30rpx;
								height: 30rpx;
								border-radius: 50%;
								background-color: #029602;
								margin-top: 10rpx;
								margin-right: 10rpx;
							}

							.text {
								font-size: 28rpx;
								color: #029602;
								font-weight: 600;
							}
						}
					}

					.thread {
						width: 4rpx;
						height: 40rpx;
						border-radius: 4rpx;
						background-image: linear-gradient(#fff, #999, #fff);
					}
				}
			}
		}
	}
</style>